from django.shortcuts import render

# Create your views here.
# def clothes(request):
#     return render(request,'index.html')


# from django.shortcuts import render
from django.views.generic import TemplateView, DetailView
from users.forms import UserRegisterForm, UserLoginForm
from .models import Market
from clothes_store import settings
from comments.models   import Comments
# from comments.forms import CommentsForm
# from comments.models import Comments

# Create your views here.


class Index(TemplateView):
    template_name = "index.html"
    # user_register_form = UserRegisterForm()
    # user_login_form = UserLoginForm()

    def get_context_data(self, **kwargs):
        # kwargs['user_register_form'] = self.user_register_form
        # kwargs['user_login_form'] = self.user_login_form
        kwargs['market'] = Market.objects.all()
        kwargs['man'] = Market.objects.filter(classify_bysex__name='man')
        kwargs['women'] = Market.objects.filter(classify_bysex__name='women')
        kwargs['kids'] = Market.objects.filter(classify_byage__name='kids')
        # kwargs['summer'] = Market.objects.filter(classify_byseason__name='summer')
        # kwargs['spring'] = Market.objects.filter(classify_byseason__name='spring')
        return super().get_context_data(**kwargs)



class Single(DetailView):
    template_name = "single.html"
    model = Market
    context_object_name = "market_detail"
    # user_register_form = UserRegisterForm()
    # user_login_form = UserLoginForm()

    def get_context_data(self, **kwargs):
        # kwargs['user_register_form'] = self.user_register_form
        # kwargs['user_login_form'] = self.user_login_form
        kwargs['user_comments'] = Comments.objects.filter(market__id=kwargs['object'].pk).order_by('-comment_time')
        return super().get_context_data(**kwargs)


class ManTshirt(TemplateView):
    template_name = "manjacket.html"
    # user_register_form = UserRegisterForm()
    # user_login_form = UserLoginForm()

    def get_context_data(self, **kwargs):
        # kwargs['user_register_form'] = self.user_register_form
        # kwargs['user_login_form'] = self.user_login_form
        kwargs['type'] = Market.objects.filter(classify_bysex__name='man').filter(classify_bytype__name='Tshirt')

        return super().get_context_data(**kwargs)

class ManJacket(TemplateView):
    template_name = "manjacket.html"
    # user_register_form = UserRegisterForm()
    # user_login_form = UserLoginForm()

    def get_context_data(self, **kwargs):
    #     kwargs['user_register_form'] = self.user_register_form
    #     kwargs['user_login_form'] = self.user_login_form
        kwargs['type'] = Market.objects.filter(classify_bysex__name='man').filter(classify_bytype__name='jacket')

        return super().get_context_data(**kwargs)



class WomenTshirt(TemplateView):
    template_name = "manjacket.html"
    # user_register_form = UserRegisterForm()
    # user_login_form = UserLoginForm()

    def get_context_data(self, **kwargs):
        kwargs['type'] = Market.objects.filter(classify_bysex__name='man').filter(classify_bytype__name='tshirt')

        return super().get_context_data(**kwargs)

class Womentshirt(TemplateView):
    template_name = "manjacket.html"
    user_register_form = UserRegisterForm()
    user_login_form = UserLoginForm()

    def get_context_data(self, **kwargs):
        kwargs['user_register_form'] = self.user_register_form
        kwargs['user_login_form'] = self.user_login_form
        kwargs['type'] = Market.objects.filter(classify_bysex__name='Women').filter(classify_bytype__name='Tshirt')
        return super().get_context_data(**kwargs)

class KidsTshirt(TemplateView):
    template_name = "manjacket.html"
    # user_register_form = UserRegisterForm()
    # user_login_form = UserLoginForm()

    def get_context_data(self, **kwargs):
        kwargs['type'] = Market.objects.filter(classify_byage__name='kids').filter(classify_bytype__name='Tshirt')

        return super().get_context_data(**kwargs)

class KidsJacket(TemplateView):
    template_name = "manjacket.html"
    # user_register_form = UserRegisterForm()
    # user_login_form = UserLoginForm()

    def get_context_data(self, **kwargs):
        kwargs['type'] = Market.objects.filter(classify_byage__name='kids').filter(classify_bytype__name='jacket')

        return super().get_context_data(**kwargs)
